package com.guocheng.base;

import com.guocheng.modules.login.model.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpSession session;

    @Autowired
    protected HttpServletResponse response;

    /**
     * 获取用户
     */
    protected User user;


    @ModelAttribute
    public void before(){
        User loginUser = (User)session.getAttribute("loginUser");
        if(loginUser!=null){
            user = loginUser;
        }
    }
}
